#include<iostream>
using namespace std;
int main()
{
	int t,x,y,total;
	cin>>t;
	for(int i=1;i<=t;i++)
	{
		cin>>x>>y;
		if(x>y)
		{
			if((x-y)%2==0)
				total=1;
			else
				total=2; 
		}
		else if(x<y)
		{
			if((y-x)%2==0)
				total=2;
			else
				total=1;
		}
		else
			total=0;
		cout<<total<<endl;
	}
    return 0;
}
